<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOrderFlowTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('order_flow', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('order_id', false, true)->comment('订单ID');
            $table->char('order_sn', 18)->comment('订单表流水号');
            $table->string('pay_sn')->comment('支付平台流水号');
            $table->bigInteger('user_id', false, true)->comment('用户ID');
            $table->decimal('price', 10, 2)->comment('金额');
            $table->timestamps();

            $table->index(['order_id', 'user_id']);
        });
        \DB::statement("ALTER TABLE `order_flow` comment '订单资金流水表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order_flow');
    }
}
